new Vue({
  el: '#app',
  data: {
    active: 2,
    tabActive: 0,
    loading: true,
    user: {},
    list: [],
    usdturl: '',
    tabs: [{
      title: '当前接单',
      list: [],
      loading: false,
      finished: false,
      page: 1,
      status: 1,
    },{
      title: '历史接单',
      list: [],
      loading: false,
      finished: false,
      page: 1,
      status: 2,
    }]
  },
  mounted () {
    this.main() 
  },
  methods: {
    main() {
      $http.get('/api/user/getUserInfo').then(res => {
        this.user = res.data.data
        return $http.get('/api/index/systemdeta')
      }).then( (res) => {
        this.usdturl = res.data.data.usdturl
      })
    },
    onLoad() {
      let tab = this.tabs[this.tabActive]
      $http.get('/api/otc/getallOrder', { status: tab.status, page: tab.page }).then(res => {
        if(!res.data.data || !res.data.data.length) {
          tab.finished = true
          return;
        }
        tab.page++;
        tab.loading = false;
        tab.list.push(...res.data.data)
      })
    },
    onTabChange() {
      let tab = this.tabs[this.tabActive]
      tab.list = []
      tab.page = 1;
      tab.loading = false;
      tab.finished = false;
    },
    onCreateOrder() {
      location.href = './createOrder.html'
    }
  }
})